﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BOSS.Framework.Search.ValueProvider
{
    class SimpleDefaultValueProvider : IDefaultValueProvider
    {
        #region IDefaultValueProvider 成员

        /// <summary>
        /// 获取指定字段的整数默认值
        /// </summary>
        /// <param name="contentType"></param>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        public int? GetDefaultValueAsInt32(string contentType, string fieldName)
        {
            return null;
        }

        /// <summary>
        /// 获取指定字段的整数默认值
        /// </summary>
        /// <param name="contentType"></param>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        public decimal? GetDefaultValueAsDecimal(string contentType, string fieldName)
        {
            return null;
        }

        /// <summary>
        /// 获取指定字段的字符串默认值
        /// </summary>
        /// <param name="contentType"></param>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        public string GetDefaultValueAsString(string contentType, string fieldName)
        {
            return string.Empty;
        }

        /// <summary>
        /// 判断指定字段的取值是否为默认值
        /// </summary>
        /// <param name="contentType"></param>
        /// <param name="fieldName"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public bool IsDefaultValue(string contentType, string fieldName, string value)
        {
            return string.IsNullOrEmpty(value);
        }

        /// <summary>
        /// 判断指定字段的取值是否为默认值
        /// </summary>
        /// <param name="contentType"></param>
        /// <param name="fieldName"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public bool IsDefaultValue(string contentType, string fieldName, decimal value)
        {
            return value == 0m;
        }

        /// <summary>
        /// 判断指定字段的取值是否为默认值
        /// </summary>
        /// <param name="contentType"></param>
        /// <param name="fieldName"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public bool IsDefaultValue(string contentType, string fieldName, int value)
        {
            return value == 0;
        }

        #endregion
    }
}
